package com.wj.controller;


import com.wj.pojo.Admin;
import com.wj.pojo.Menu;
import com.wj.service.IMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wj
 * @since 2022-03-06
 */
@Api(tags = "菜单控制器")
@RestController
@RequestMapping("/system")
public class MenuController {
    @Autowired
    private IMenuService menuService;
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @ApiOperation(value = "通过用户id查询菜单列表")
    @GetMapping("/menu")
    public List<Menu> getMenusByAdminId() {
        Admin principal = (Admin) (SecurityContextHolder.getContext().getAuthentication().getPrincipal());
        return menuService.getMenusByAdminId(principal.getId());
    }
}
